import { SkillInfo } from "../../../model/SkillInfo";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { Cache } from "../../../cache/Cache";
import { EGuildStructureType } from "../../../../../Message/Public/EGuildStructureType";
import { TSkill } from "../../../../../Message/Db/Tables/TSkill";
type int = number;
//class GuildSkillToolTip
    
    export  class GuildSkillToolTip /* flash.display.Sprite */
    {
        constructor(arg1: SkillInfo=null)
        {
            
            this.init();
            this.data = arg1;
            return;
        }

        public set data(arg1: SkillInfo)
        {
            this._skillInfo = arg1;
            this._skill = arg1.tSkill;
            this._isLearned = arg1.learned;
            if (this._skill) 
            {
                this._currentY = 0;
                this._nameTxt.htmlText = this._skill.skillName;
                if (this._isLearned) 
                {
                    this._levelTxt.text = this._skill.skillLevel.toString();
                    this._descTxt.htmlText = "<textFormat leading=\'5\'>" + this._skill.skillDescription + "</textFormat>";
                    this._nextSkill = arg1.nextSkill;
                }
                else 
                {
                    this._levelTxt.text = "0";
                    this._descTxt.htmlText = Language.getString(57581);
                    this._nextSkill = arg1.tSkill;
                }
                this._currentY = this._currentY + (this._descTxt.y + this._descTxt.height + 5);
                if (this._nextSkill) 
                {
                    if (!this._nextLine) 
                    {
                        this._nextLine = ObjCreate.createBg(0, this._currentY, this.width, 1, null, ImagesConst.SeptalLine);
                    }
                    if (!this.contains(this._nextLine)) 
                    {
                        this.addChild(this._nextLine);
                    }
                    this._nextLine.y = this._currentY;
                    this._currentY = this._currentY + 5;
                    if (!this._nextTxt) 
                    {
                        this._nextTxt = ObjCreate.createTextField("", 10, 0, this.width - 20, 20, null, GlobalStyle.textFormat4);
                        this._nextTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
                        this._nextTxt.wordWrap = true;
                        this._nextTxt.multiline = true;
                    }
                    if (!this.contains(this._nextTxt)) 
                    {
                        this.addChild(this._nextTxt);
                    }
                    this._nextTxt.y = this._currentY;
                    this._nextTxt.htmlText = this.getNextSkillTip();
                    this._currentY = this._currentY + (this._nextTxt.height + 5);
                }
                else 
                {
                    if (this._nextLine && this.contains(this._nextLine)) 
                    {
                        this.removeChild(this._nextLine);
                    }
                    if (this._nextTxt && this.contains(this._nextTxt)) 
                    {
                        this.removeChild(this._nextTxt);
                    }
                }
                this._needLine.y = this._currentY;
                this._needTxt.y = this._currentY + 5;
                this._needTxt.htmlText = this.getNeedTip();
            }
            return;
        }

        /* internal  */init(): void
        {
            var loc1=10;
            this._nameTxt = ObjCreate.createTextField("", 0, 0, this.width, 20, this, new GTextFormat(FontUtil.songtiName, 14, 16711935, true));
            this._nameTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            ObjCreate.createTextField(Language.getString(57549), loc1, 25, this.width, 20, this);
            ObjCreate.createTextField(Language.getString(57576), loc1, 45, this.width, 20, this, GlobalStyle.textFormat6);
            this._levelTxt = ObjCreate.createTextField("1", loc1 + 65, 45, this.width, 20, this, GlobalStyle.textFormat6);
            this._descTxt = ObjCreate.createTextField("", loc1, 65, this.width - 20, 20, this, GlobalStyle.textFormatGreen);
            this._descTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._descTxt.wordWrap = true;
            this._descTxt.multiline = true;
            this._needLine = ObjCreate.createBg(0, 0, this.width, 1, this, ImagesConst.SeptalLine);
            this._needTxt = ObjCreate.createTextField("", 10, 0, this.width, 20, this);
            this._needTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            return;
        }

        /* internal  */getNextSkillTip(): string
        {
            var loc1="";
            loc1 = loc1 + Language.getStringByParam(57577, this._nextSkill.skillLevel);
            loc1 = loc1 + this._nextSkill.skillDescription;
            loc1 = "<textFormat leading=\'5\'>" + loc1 + "</textFormat>";
            return loc1;
        }

        /* internal  */getNeedTip(): string
        {
            var loc3=0;
            var loc1="#f0ea3f";
            var loc2=Cache.instance.guild.getStructureLevel(EGuildStructureType.convert(EGuildStructureType._EGuildSchool));
            if (this._nextSkill) 
            {
                loc3 = this._nextSkill.guildSchoolLevel;
            }
            else 
            {
                loc3 = this._skill.guildSchoolLevel;
            }
            if (loc2 < loc3) 
            {
                loc1 = "#ff0000";
            }
            var loc4=Language.getStringByParam(57578, loc1, this._nextSkill.guildSchoolLevel);
            return loc4 = "<textFormat leading=\'5\'>" + loc4 + "</textFormat>";
        }

        public /* override */ get width(): number
        {
            return 200;
        }

        /* internal */ /* var */_nameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_levelTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_descTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_nextTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_needTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_nextLine: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_needLine: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_currentY: int;

        /* internal */ /* var */_skillInfo: SkillInfo;

        /* internal */ /* var */_skill: TSkill;

        /* internal */ /* var */_nextSkill: TSkill;

        /* internal */ /* var */_isLearned: Boolean;
    }
